<?php

    if (!defined('EXPONENT')) exit('');

    global $db;

    $id=0;
    if(isset($_REQUEST['src']))
    {
        $src = $_REQUEST['src'];
    }
    if (isset($_REQUEST['id']))
        $id=intval($_REQUEST['id']);
    else if (isset($_REQUEST['name']))
        {
            $name = explode("_",$_REQUEST['name']);
            if (!(count($name) > 1))
            {
                echo SITE_404_HTML;
            }
            else
            {
                $id=intval($name[0]);
            }
        }

    if ($id == 0)
    {        
        exponent_http_error(404);
    }
    else
    {
        $link = $db->selectObject('linklist_link',"location_data='".serialize($loc)."' AND (id = {$id})");
        
        if ($link)
        {
            // get module config
            $config = $db->selectObject("linklistmodule_config", "location_data = '".serialize($loc)."'");
            if (!isset($config->show_date))
                $config->show_date = 0;
            
            
            // check file id
            if ($link->file_id <= 0) {
                $link->picpath = '';
            } else {
                $file = $db->selectObject('file', 'id='.$link->file_id);
                $link->picpath = "/".$file->directory.'/'.$file->filename;
            }
            
            // date
            $link->full_date = strftime(DISPLAY_DATETIME_FORMAT,$link->post_date);

            $template = new template('linklistmodule','_OurTeam_viewDetail',$loc);
            $template->assign('link',$link);
            $template->assign('config',$config);
            $template->assign('team',1);
            $template->register_permissions(
            array('administrate','configure','create','edit','delete'   ),$loc);
            $template->output();
            exponent_sessions_set("AB_THEME_RIGHT_MENU_SRC",$loc->src);
            _ab_theme_action_register_title($link->name);
            
            // for senten at the top - PROJECT HASAN CREDIT
            if (isset($config->force_top_sentence) && ($config->force_top_sentence))
            {
                if ($link->team_usedifference_topsrc)
                    exponent_sessions_set("AB_THEME_TOP_CONTAINER_SRC","top_".$loc->src."_staff_".$link->name."_".LANG);
                else
                    exponent_sessions_set("AB_THEME_TOP_CONTAINER_SRC","top_".$loc->src."_".LANG);
            }
        }
        else
        {
            echo exponent_http_error(404);
        }
    }
?>